﻿#region LGPL License

/*
OpenSearchNet
Copyright (c) 2014, Brad Hards <bradh@frogmouth.net>, All rights reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library.
*/

#endregion LGPL License

namespace OpenSearch.Osdd
{
    internal enum EnumSyndicationRight { open, limited, privte, closed };

    /// <summary>
    /// Syndication Rights from an OpenSearch Description Document
    /// </summary>
    public class SyndicationRights
    {
        private EnumSyndicationRight right = EnumSyndicationRight.open;

        internal SyndicationRights()
        {
            right = EnumSyndicationRight.open;
        }

        internal SyndicationRights(System.Xml.XmlReader reader)
        {
            string xmlValue = reader.ReadString();
            switch (xmlValue.ToUpperInvariant())
            {
                case "OPEN":
                    right = EnumSyndicationRight.open;
                    break;

                case "LIMITED":
                    right = EnumSyndicationRight.limited;
                    break;

                case "PRIVATE":
                    right = EnumSyndicationRight.privte;
                    break;

                case "CLOSED":
                    right = EnumSyndicationRight.closed;
                    break;

                default:
                    right = EnumSyndicationRight.open;
                    break;
            }
        }

        /// <inheritdoc/>
        public override string ToString()
        {
            switch (right)
            {
                case EnumSyndicationRight.open:
                    return "open";
                case EnumSyndicationRight.limited:
                    return "limited";
                case EnumSyndicationRight.privte:
                    return "private";
                case EnumSyndicationRight.closed:
                    return "closed";
                default:
                    return "unknown";
            }
        }
    }
}